*****************************************************************************************************************************************************
* PROJECT: 		Exposure to the COVID-19 Stock Market Crash and its Effect on Household Expectations
* DATE: 		Nov 2020
* CONTENT: 		TABLES
* AUTHORS: 		Tobin Hanspal, Johannes Wohlfart, Anni Weber
*****************************************************************************************************************************************************

		clear all
		set scheme lean2
		global pm = char(177)
		set more off
		gl date = c(current_date)
		graph set window fontface "cmr10"		
		
* set cd as /Replication_files_HanspalWeberWohlfart2020/


*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~						
** Table 5
*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~	
	
use data/processed/data_1, clear 

replace planned_morestocks=. if stockowner==0
replace planned_lessstocks=. if stockowner==0

foreach var of varlist expec_debthigher expec_morehrs expec_retirlater never_ownwealth never_owninc ///
realized_anychangestocks realized_morestocks realized_lessstocks planned_anychangestocks planned_morestocks planned_lessstocks {

gen `var'_00=100* `var' 

}
* 

global controls ln_hhnetinc hhnetinc19_NR ///
	ln_ofinwealth_lvl ln_retirewealth_lvl ///
	ln_realestate_lvl realestJan20_NR ///
	ln_debt_lvl  debtJan20_NR ///
	stockinvestor riskshare_finwealth_Jan201 stockexperience ///
	i.agecat male married separated_divorced widowed ///	
	highschool some_college_associate_degree atleast_bachelor  ///
	z_decisionmaker mainearner_alone self_empl retired unempl empl_other z_constrained ///
	republican other_party NR_party  ///
	i.region ///
	i.svydate


loc experiments "recov_hhwealth_duration z_finprospect planned_morestocks_00 planned_lessstocks_00 del_spend20_perc_tr02 expec_debthigher_00 expec_morehrs_00 expec_retirlater_00"
loc experiments1 "recov_hhwealth_duration z_finprospect"
loc experiments2 "del_spend20_perc_tr02 expec_debthigher_00 expec_morehrs_00 expec_retirlater_00"

preserve

clear all
eststo clear
estimates drop _all

set obs 10
qui gen x = 1
qui gen y = 1

loc columns = 0

foreach choice in `experiments' {

    loc ++columns
    qui eststo col`columns': reg x y

}

restore

loc colnum = 1
loc colnames ""


foreach choice in `experiments1' {

ivreg2 `choice' recovery_duration $controls i.treatment, r, if treated!=1

local N=e(N)
local r2=round(e(r2_a),.001)

sigstar recovery_duration , prec(3)
estadd loc thisstat2 = "`r(bstar)'": col`colnum'
estadd loc thisstat3 = "`r(sestar)'": col`colnum'
estadd loc thisstat4= `N': col`colnum'

ivreg2 `choice' recovery_duration $controls i.treatment, r, if treated!=1 & stockowner==1

local N=e(N)
local r2=round(e(r2_a),.001)

sigstar recovery_duration , prec(3)
estadd loc thisstat7 = "`r(bstar)'": col`colnum'
estadd loc thisstat8 = "`r(sestar)'": col`colnum'
estadd loc thisstat9= `N': col`colnum'


ivreg2 `choice' recovery_duration prior $controls, r, if arm_fincrisis==1 & percgap>0 & stockowner==1

local N=e(N)
local r2=round(e(r2_a),.001)

sigstar recovery_duration , prec(3)
estadd loc thisstat12 = "`r(bstar)'": col`colnum'
estadd loc thisstat13 = "`r(sestar)'": col`colnum'

ivreg2 `choice' (recovery_duration=treated) prior $controls, r, if arm_fincrisis==1 & percgap>0 & stockowner==1

local N=e(N)
local r2=round(e(r2_a),.001)
local F=round(e(widstat),.001)

sigstar recovery_duration , prec(3)
estadd loc thisstat15 = "`r(bstar)'": col`colnum'
estadd loc thisstat16 = "`r(sestar)'": col`colnum'

estadd loc thisstat18= `F': col`colnum'
estadd loc thisstat19= `N': col`colnum'



ivreg2 `choice' recovery_duration prior $controls, r, if arm_dotcom==1 & percgap>0 & stockowner==1

local N=e(N)
local r2=round(e(r2_a),.001)

sigstar recovery_duration , prec(3)
estadd loc thisstat22 = "`r(bstar)'": col`colnum'
estadd loc thisstat23 = "`r(sestar)'": col`colnum'

ivreg2 `choice' (recovery_duration=treated) prior $controls, r, if arm_dotcom==1 & percgap>0 & stockowner==1

local N=e(N)
local r2=round(e(r2_a),.001)
local F=round(e(widstat),.001)

sigstar recovery_duration , prec(3)
estadd loc thisstat25 = "`r(bstar)'": col`colnum'
estadd loc thisstat26 = "`r(sestar)'": col`colnum'

estadd loc thisstat28= `F': col`colnum'
estadd loc thisstat29= `N': col`colnum'



ivreg2 `choice' recovery_duration prior $controls, r, if arm_black==1 & percgap<0 & stockowner==1

local N=e(N)
local r2=round(e(r2_a),.001)

sigstar recovery_duration , prec(3)
estadd loc thisstat32 = "`r(bstar)'": col`colnum'
estadd loc thisstat33 = "`r(sestar)'": col`colnum'

ivreg2 `choice' (recovery_duration=treated) prior $controls, r, if arm_black==1 & percgap<0 & stockowner==1

local N=e(N)
local r2=round(e(r2_a),.001)
local F=round(e(widstat),.001)

sigstar recovery_duration , prec(3)
estadd loc thisstat35 = "`r(bstar)'": col`colnum'
estadd loc thisstat36 = "`r(sestar)'": col`colnum'

estadd loc thisstat38= `F': col`colnum'
estadd loc thisstat39= `N': col`colnum'

estadd loc thisstat41 "Yes": col`colnum'

loc ++colnum
loc colnames "`colnames' `"`: var la `choice''"'"

}


ivreg2 planned_morestocks_00 recovery_duration i.stocktrades_realized $controls i.treatment, r, if treated!=1

local N=e(N)
local r2=round(e(r2_a),.001)

sigstar recovery_duration , prec(3)
estadd loc thisstat2 = "`r(bstar)'": col`colnum'
estadd loc thisstat3 = "`r(sestar)'": col`colnum'
estadd loc thisstat4= `N': col`colnum'

ivreg2 planned_morestocks_00 recovery_duration i.stocktrades_realized $controls i.treatment, r, if treated!=1 & stockowner==1

local N=e(N)
local r2=round(e(r2_a),.001)

sigstar recovery_duration , prec(3)
estadd loc thisstat7 = "`r(bstar)'": col`colnum'
estadd loc thisstat8 = "`r(sestar)'": col`colnum'
estadd loc thisstat9= `N': col`colnum'


ivreg2 planned_morestocks_00 recovery_duration i.stocktrades_realized prior $controls, r, if arm_fincrisis==1 & percgap>0 & stockowner==1

local N=e(N)
local r2=round(e(r2_a),.001)

sigstar recovery_duration , prec(3)
estadd loc thisstat12 = "`r(bstar)'": col`colnum'
estadd loc thisstat13 = "`r(sestar)'": col`colnum'

ivreg2 planned_morestocks_00 (recovery_duration=treated) i.stocktrades_realized prior $controls, r, if arm_fincrisis==1 & percgap>0 & stockowner==1

local N=e(N)
local r2=round(e(r2_a),.001)
local F=round(e(widstat),.001)

sigstar recovery_duration , prec(3)
estadd loc thisstat15 = "`r(bstar)'": col`colnum'
estadd loc thisstat16 = "`r(sestar)'": col`colnum'

estadd loc thisstat18= `F': col`colnum'
estadd loc thisstat19= `N': col`colnum'



ivreg2 planned_morestocks_00 recovery_duration i.stocktrades_realized prior $controls, r, if arm_dotcom==1 & percgap>0 & stockowner==1

local N=e(N)
local r2=round(e(r2_a),.001)

sigstar recovery_duration , prec(3)
estadd loc thisstat22 = "`r(bstar)'": col`colnum'
estadd loc thisstat23 = "`r(sestar)'": col`colnum'

ivreg2 planned_morestocks_00 (recovery_duration=treated) i.stocktrades_realized prior $controls, r, if arm_dotcom==1 & percgap>0 & stockowner==1

local N=e(N)
local r2=round(e(r2_a),.001)
local F=round(e(widstat),.001)

sigstar recovery_duration , prec(3)
estadd loc thisstat25 = "`r(bstar)'": col`colnum'
estadd loc thisstat26 = "`r(sestar)'": col`colnum'

estadd loc thisstat28= `F': col`colnum'
estadd loc thisstat29= `N': col`colnum'



ivreg2 planned_morestocks_00 recovery_duration i.stocktrades_realized prior $controls, r, if arm_black==1 & percgap<0 & stockowner==1

local N=e(N)
local r2=round(e(r2_a),.001)

sigstar recovery_duration , prec(3)
estadd loc thisstat32 = "`r(bstar)'": col`colnum'
estadd loc thisstat33 = "`r(sestar)'": col`colnum'

ivreg2 planned_morestocks_00 (recovery_duration=treated) i.stocktrades_realized prior $controls, r, if arm_black==1 & percgap<0 & stockowner==1

local N=e(N)
local r2=round(e(r2_a),.001)
local F=round(e(widstat),.001)

sigstar recovery_duration , prec(3)
estadd loc thisstat35 = "`r(bstar)'": col`colnum'
estadd loc thisstat36 = "`r(sestar)'": col`colnum'

estadd loc thisstat38= `F': col`colnum'
estadd loc thisstat39= `N': col`colnum'

estadd loc thisstat41 "Yes": col`colnum'

loc ++colnum
loc colnames "`colnames' `"`: var la `choice''"'"




ivreg2 planned_lessstocks_00 recovery_duration i.stocktrades_realized $controls i.treatment, r, if treated!=1

local N=e(N)
local r2=round(e(r2_a),.001)

sigstar recovery_duration , prec(3)
estadd loc thisstat2 = "`r(bstar)'": col`colnum'
estadd loc thisstat3 = "`r(sestar)'": col`colnum'
estadd loc thisstat4= `N': col`colnum'

ivreg2 planned_lessstocks_00 recovery_duration i.stocktrades_realized $controls i.treatment, r, if treated!=1 & stockowner==1

local N=e(N)
local r2=round(e(r2_a),.001)

sigstar recovery_duration , prec(3)
estadd loc thisstat7 = "`r(bstar)'": col`colnum'
estadd loc thisstat8 = "`r(sestar)'": col`colnum'
estadd loc thisstat9= `N': col`colnum'


ivreg2 planned_lessstocks_00 recovery_duration i.stocktrades_realized prior $controls, r, if arm_fincrisis==1 & percgap>0 & stockowner==1

local N=e(N)
local r2=round(e(r2_a),.001)

sigstar recovery_duration , prec(3)
estadd loc thisstat12 = "`r(bstar)'": col`colnum'
estadd loc thisstat13 = "`r(sestar)'": col`colnum'

ivreg2 planned_lessstocks_00 (recovery_duration=treated) i.stocktrades_realized prior $controls, r, if arm_fincrisis==1 & percgap>0 & stockowner==1

local N=e(N)
local r2=round(e(r2_a),.001)
local F=round(e(widstat),.001)

sigstar recovery_duration , prec(3)
estadd loc thisstat15 = "`r(bstar)'": col`colnum'
estadd loc thisstat16 = "`r(sestar)'": col`colnum'

estadd loc thisstat18= `F': col`colnum'
estadd loc thisstat19= `N': col`colnum'



ivreg2 planned_lessstocks_00 recovery_duration i.stocktrades_realized prior $controls, r, if arm_dotcom==1 & percgap>0 & stockowner==1

local N=e(N)
local r2=round(e(r2_a),.001)

sigstar recovery_duration , prec(3)
estadd loc thisstat22 = "`r(bstar)'": col`colnum'
estadd loc thisstat23 = "`r(sestar)'": col`colnum'

ivreg2 planned_lessstocks_00 (recovery_duration=treated) i.stocktrades_realized prior $controls, r, if arm_dotcom==1 & percgap>0 & stockowner==1

local N=e(N)
local r2=round(e(r2_a),.001)
local F=round(e(widstat),.001)

sigstar recovery_duration , prec(3)
estadd loc thisstat25 = "`r(bstar)'": col`colnum'
estadd loc thisstat26 = "`r(sestar)'": col`colnum'

estadd loc thisstat28= `F': col`colnum'
estadd loc thisstat29= `N': col`colnum'



ivreg2 planned_lessstocks_00 recovery_duration i.stocktrades_realized prior $controls, r, if arm_black==1 & percgap<0 & stockowner==1

local N=e(N)
local r2=round(e(r2_a),.001)

sigstar recovery_duration , prec(3)
estadd loc thisstat32 = "`r(bstar)'": col`colnum'
estadd loc thisstat33 = "`r(sestar)'": col`colnum'

ivreg2 planned_lessstocks_00 (recovery_duration=treated) i.stocktrades_realized prior $controls, r, if arm_black==1 & percgap<0 & stockowner==1

local N=e(N)
local r2=round(e(r2_a),.001)
local F=round(e(widstat),.001)

sigstar recovery_duration , prec(3)
estadd loc thisstat35 = "`r(bstar)'": col`colnum'
estadd loc thisstat36 = "`r(sestar)'": col`colnum'

estadd loc thisstat38= `F': col`colnum'
estadd loc thisstat39= `N': col`colnum'

estadd loc thisstat41 "Yes": col`colnum'

loc ++colnum
loc colnames "`colnames' `"`: var la `choice''"'"




foreach choice in `experiments2' {

ivreg2 `choice' recovery_duration $controls i.treatment, r, if treated!=1

local N=e(N)
local r2=round(e(r2_a),.001)

sigstar recovery_duration , prec(3)
estadd loc thisstat2 = "`r(bstar)'": col`colnum'
estadd loc thisstat3 = "`r(sestar)'": col`colnum'
estadd loc thisstat4= `N': col`colnum'

ivreg2 `choice' recovery_duration $controls i.treatment, r, if treated!=1 & stockowner==1

local N=e(N)
local r2=round(e(r2_a),.001)

sigstar recovery_duration , prec(3)
estadd loc thisstat7 = "`r(bstar)'": col`colnum'
estadd loc thisstat8 = "`r(sestar)'": col`colnum'
estadd loc thisstat9= `N': col`colnum'


ivreg2 `choice' recovery_duration prior $controls, r, if arm_fincrisis==1 & percgap>0 & stockowner==1

local N=e(N)
local r2=round(e(r2_a),.001)

sigstar recovery_duration , prec(3)
estadd loc thisstat12 = "`r(bstar)'": col`colnum'
estadd loc thisstat13 = "`r(sestar)'": col`colnum'

ivreg2 `choice' (recovery_duration=treated) prior $controls, r, if arm_fincrisis==1 & percgap>0 & stockowner==1

local N=e(N)
local r2=round(e(r2_a),.001)
local F=round(e(widstat),.001)

sigstar recovery_duration , prec(3)
estadd loc thisstat15 = "`r(bstar)'": col`colnum'
estadd loc thisstat16 = "`r(sestar)'": col`colnum'

estadd loc thisstat18= `F': col`colnum'
estadd loc thisstat19= `N': col`colnum'



ivreg2 `choice' recovery_duration prior $controls, r, if arm_dotcom==1 & percgap>0 & stockowner==1

local N=e(N)
local r2=round(e(r2_a),.001)

sigstar recovery_duration , prec(3)
estadd loc thisstat22 = "`r(bstar)'": col`colnum'
estadd loc thisstat23 = "`r(sestar)'": col`colnum'

ivreg2 `choice' (recovery_duration=treated) prior $controls, r, if arm_dotcom==1 & percgap>0 & stockowner==1

local N=e(N)
local r2=round(e(r2_a),.001)
local F=round(e(widstat),.001)

sigstar recovery_duration , prec(3)
estadd loc thisstat25 = "`r(bstar)'": col`colnum'
estadd loc thisstat26 = "`r(sestar)'": col`colnum'

estadd loc thisstat28= `F': col`colnum'
estadd loc thisstat29= `N': col`colnum'



ivreg2 `choice' recovery_duration prior $controls, r, if arm_black==1 & percgap<0 & stockowner==1

local N=e(N)
local r2=round(e(r2_a),.001)

sigstar recovery_duration , prec(3)
estadd loc thisstat32 = "`r(bstar)'": col`colnum'
estadd loc thisstat33 = "`r(sestar)'": col`colnum'

ivreg2 `choice' (recovery_duration=treated) prior $controls, r, if arm_black==1 & percgap<0 & stockowner==1

local N=e(N)
local r2=round(e(r2_a),.001)
local F=round(e(widstat),.001)

sigstar recovery_duration , prec(3)
estadd loc thisstat35 = "`r(bstar)'": col`colnum'
estadd loc thisstat36 = "`r(sestar)'": col`colnum'

estadd loc thisstat38= `F': col`colnum'
estadd loc thisstat39= `N': col`colnum'

estadd loc thisstat41 "Yes": col`colnum'

loc ++colnum
loc colnames "`colnames' `"`: var la `choice''"'"

}


loc rowlabels " "{\bf Panel A: All control groups (OLS)}" "Expected stock recovery duration (years)" " " "Observations" " " "{\bf Panel B: All control groups\&$\text{Stocks}$ (OLS)}" "Expected stock recovery duration (years)" " " "Observations" " " "\hline {\bf Panel C: Fin. Cris. Und.\&$\text{Stocks}$ (OLS)}" "Expected stock recovery duration (years)" " " "{\bf Panel D: Fin. Cris. Und.\&$\text{Stocks}$ (2SLS)}" "Expected stock recovery duration (years)" " " " " "First-stage F-stat" "Observations" " " "\hline {\bf Panel E: Dot-com Und.\&$\text{Stocks}$ (OLS)}" "Expected stock recovery duration (years)" " " "{\bf Panel F: Dot-com Und.\&$\text{Stocks}$ (2SLS)}" "Expected stock recovery duration (years)" " " " " "First-stage F-stat" "Observations" " " "\hline {\bf Panel G: Black Mon. Over.\&$\text{Stocks}$ (OLS)}" "Expected stock recovery duration (years)" " " "{\bf Panel H: Black Mon. Over.\&$\text{Stocks}$ (2SLS)}" "Expected stock recovery duration (years)" " " " " "First-stage F-stat" "Observations" " " "\hline Individual controls" " 


forval i = 1/41 {
    loc rowstats "`rowstats' thisstat`i'"
}

esttab * using "Tables\Table5.tex", replace cells(none) booktabs nonotes nomtitles compress alignment(c) nogap noobs nobaselevels label stats(`rowstats', labels(`rowlabels')) ///
     mgroups("\shortstack{Wealth\\recovery\\duration}" "\shortstack{Household\\ financial \\ prospects}" "\shortstack{Plan incr. \\ stock \\ share}" "\shortstack{Plan decr. \\ stock \\ share}"  "\shortstack{Exp.\\spend.\\growth}" "\shortstack{Incr.\\ exp.\\ debt}" "\shortstack{Incr. exp. \\ desired \\ hours}" "\shortstack{Incr. exp.\\ retirement \\ age}" , pattern(1 1 1 1 1 1 1 1  ) prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span}))




